package com.msb.controller;

import com.msb.pojo.Emp;
import com.msb.service.impl.EmpserviceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.logging.Logger;

/**
 * @ClassName: EmpController
 * @Author: zw
 * @Description: 出百万拳，行万里路；
 * @Create 2024/5/19-23:08
 * @Version 1.0
 */
@Controller
@RequestMapping("/emps")
public class EmpController {
    // autowired 注入对象
    private Logger logger = Logger.getLogger("EmpController");
    @Autowired
    private EmpserviceImpl empService;

//    @ResponseBody
//    @GetMapping("/findemp")
//    public String findEmps() {
//       return "hello findemps";
//    }

    @ResponseBody
    @GetMapping("test")
    public int test(@RequestParam("id") int id) {
        return  id;
    }
    @PostMapping("/testmysql")
    public String testmysql(@RequestParam("id") int id) {
        return "success";
    }

    @ResponseBody
    @PostMapping("/findEmp")
    public String findEmpById(@RequestParam("id") int id) {
        logger.info("id:" + id);

        return empService.findEmpById(id);
    }

    @ResponseBody
    @GetMapping("/findEmps/{id}")
    public Emp findEmpsbyId(@PathVariable("id") int id) {
        return empService.findEmpsById(id);
    }

    @ResponseBody
    @PostMapping("/findEmps")
    public List<Emp> findAllEmps(@RequestParam Emp emp) {
        return empService.findAllEmps(emp);
    }
}
